/**
 * 应用方案
 * 校验规则
 */
const { query, checkSchema } = require("express-validator");

module.exports = {
  // 产品列表
  getApplicationSolutionList_validation: [query("page").default(1).toInt().isInt({ min: 1 }).withMessage("请输入页码"), query("limit").default(10).toInt().isInt({ min: 1 }).withMessage("请输入每页数量")],
  // 产品详情
  getApplicationSolutionDetail_validation: checkSchema({
    solution_id: {
      in: ["query"],
      toInt: true,
      isInt: {
        min: 1,
      },
      errorMessage: "请输入应用方案ID",
    },
  }),
  // 编辑产品
  editApplicationSolution_validation: checkSchema({
    solution_id: {
      in: ["body"],
      toInt: true,
      isInt: {
        min: 1,
      },
      errorMessage: "请输入正确应用方案ID",
      trim: true,
      optional: true,
    },
    title: {
      in: ["body"],
      notEmpty: true,
      trim: true,
      errorMessage: "请输入应用方案标题",
    },
    content: {
      in: ["body"],
      errorMessage: "请输入应用方案内容",
      customSanitizer: {
        options: (value) => value || "",
      },
    },
    cover: {
      in: ["body"],
      trim: true,
      errorMessage: "请输入应用方案封面",
      customSanitizer: {
        options: (value) => value || "",
      },
    },
  }),
};
